package navigate;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

// 游览器导航
public class NavigateTest {
    ChromeDriver driver = new ChromeDriver();

    @Test
    public void test() throws InterruptedException {
        // 创建游览器驱动
        // 进行隐式等待
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
        // ⭐进行显示等待
        // new WebDriverWait(driver, Duration.ofSeconds(10))
//                .until(driver -> driver.findElement(By.cssSelector("#kw")));
        driver.get("https://www.baidu.com");
        driver.findElement(By.cssSelector("#kw")).sendKeys("蔡徐坤");
        // 点击百度一下
        driver.findElement(By.cssSelector("#su")).click();
        // 回退
        driver.navigate().back();
        // 前进
        driver.navigate().forward();
        // 刷新
        driver.navigate().refresh();

        driver.quit();
    }
}
